package provider;

import anaydis.sort.Sorter;
import anaydis.sort.SorterType;
import anaydis.sort.provider.SorterProvider;
import impl.sort.*;

import java.util.EnumMap;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: Tomi
 * Date: 24/08/2011
 * Time: 15:20:32
 * To change this template use File | Settings | File Templates.
 */
public class SorterProviderImpl implements SorterProvider {
    private Map<SorterType, Sorter> map;
    public SorterProviderImpl(){
        map = new EnumMap<SorterType, Sorter>(SorterType.class);
        map.put(SorterType.BUBBLE, new BubbleSorter());
        map.put(SorterType.SELECTION, new SelectionSorter());
        map.put(SorterType.INSERTION, new InsertionSorter());
        map.put(SorterType.H, new HSorter());
        map.put(SorterType.SHELL, new ShellSorter());
        map.put(SorterType.QUICK, new QuickSorter());
        map.put(SorterType.QUICK_NON_RECURSIVE, new QuickNRSorter());
        map.put(SorterType.QUICK_CUT, new QuickCutOffSorter());
        map.put(SorterType.QUICK_MED_OF_THREE, new QuickMedianOfThreeSorter());
        map.put(SorterType.QUICK_THREE_PARTITION, new QuickThreeWaySorter());
        map.put(SorterType.MERGE, new MergeTopDownSorter());
        map.put(SorterType.MERGE_BOTTOM_UP, new MergeBottomUpSorter());
        map.put(SorterType.HEAP, new HeapSorter());
        map.put(SorterType.HEAP_TERNARY, new HeapTernarySorter());
    }
    public Sorter getSorterForType(SorterType sorterType) {
        return map.get(sorterType);
    }
    public Iterable<Sorter> getAllSorters() {
        return map.values();
    }
}